<?php

namespace EmailDelivery\Templates\Support;

use Users\Profile;
use Pinenut\Service\UrlManager\WithLanguage;

/**
 * Created by ITokarev
 * 
 * Email Delivery Template for Guest Support Message
 */

class TemplateAction extends \Action
{
	protected static $layout = '#emailDelivery.templates.layout';
		
	protected function run()
	{
		if (!$this->request->email)
		{
		    throw new \Exception('Email Not Found', 500);
		}

 		$userName = $this->request->nickname;
		
		$profile = Profile::find($this->request->userId);
		
		if(!$userName)
		{
			$userName = $profile->nickname;
		}
		
		$this->response->profile = $profile;
				
		$this->response->set('title', 'Support');
		$this->response->set('to', $this->request->email);
		
		$this->response->problemType = $this->request->problemType;
		$this->response->userDescription = $this->request->userDescription;
		$this->response->supportAnswer = $this->request->supportAnswer;
		$this->response->userName = $userName;
        
	}
}